<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>转优车流程发起页面</title>
<jsp:include page="../../import.jsp" flush="true" />
<jsp:include page="../assParking/assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<div id="pageInTab" class="pageInTab">
				<!-- 页签1：转优车申请 -->
				<div tabid="tabA" title="拖车单信息" lselected="true">
					<form id="optimalCar">
						<div class="fieldset1 tabel_col clearFix">
							<div class="fieldBox col_50">
								<div class="label">申请人</div>
				                <div class="field">
				                    <span id="applyNm" name="applyNm">&nbsp;</span>
				                </div>
							</div>
				            <div class="fieldBox col_50">
								<div class="label">申请时间</div>
								<div class="field">
									<span id="applyDt" name="applyDt">&nbsp;</span>
								</div>
							</div>
							<!-- 基本信息 -->
							<div class="caption">
								<span class="title">基本信息</span>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">承租人</div>
								<div class="field">
									<span id="cstNm_1" name="cstNm_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">合同编号</div>
								<div class="field">
									<span id="contNo" name="contNo">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33">
				                <div class="label">支付表号</div>
				                <div class="field">
				                    <span id="paySchNo" name="paySchNo">&nbsp;</span>
				                </div>
				            </div>
				            <div class="fieldBox col_33">
								<div class="label">经销商</div>
								<div class="field">
									<span id="splNm" name="splNm">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">事业部</div>
								<div class="field">
									<span id="orgName_1" name="orgName_1">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">业务负责人</div>
								<div class="field" style="width: 100%;">
									<span id="cstMgrNm" name="cstMgrNm">&nbsp;</span>
								</div>
							</div>
							<!-- 设备信息 -->
							<div class="caption">
								<span class="title">设备信息</span>
							</div>
							<div class="fieldBox col_100">
								<div class="sqPanel">
									<div id="detailGrid">
										<!-- 设备信息列表显示块 -->
										<div id="ligergrid_equ" class="sq-grid"></div>
									</div>
								</div>
							</div>
							<!-- 逾期信息 -->
							<div class="caption">
								<span class="title">逾期信息</span>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">租赁周期</div>
								<div class="field">
									<span id="lsPd" name="lsPd">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">已还租金(元)</div>
								<div class="field">
									<span id="actualAmt" name="actualAmt">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33">
				                <div class="label">逾期租金(元)</div>
				                <div class="field">
				                    <span id="overdueAmt" name="overdueAmt">&nbsp;</span>
				                </div>
				            </div>
				            <div class="fieldBox col_33">
								<div class="label">逾期天数</div>
								<div class="field">
									<span id="overdueDay" name="overdueDay">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">罚息金额(元)</div>
								<div class="field">
									<span id="penaltyAmt" name="penaltyAmt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">应还款金额(元)</div>
								<div class="field">
									<span id="payAmt" name="payAmt">&nbsp;</span>
								</div>
							</div>
							<!-- 拖车信息 -->
							<div class="caption">
								<span class="title">拖车信息</span>
							</div>
				            <div class="fieldBox col_100">
								<div class="label">拖车原因</div>
								<div class="field">
									<span id="backReason" name="backReason">&nbsp;</span>
								</div>
							</div>
							<!-- 附件显示 -->
							<div class="fieldBox col_100">
								<div style="width: 98%; margin-left: 1%;">
									<jsp:include page="../assCommFilesList.jsp" flush="true" ></jsp:include>
									<div id="ligergrid_file2" class="sq-grid"></div>
								</div>
							</div>
							<!-- 可编辑信息 -->
							<div class="fieldBox col_33">
								<div class="label">拖车单位名称</div>
								<div class="field">
									<span id="companyNm" name="companyNm">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">预计拖回时间</div>
								<div class="field">
									<span id="backDt" name="backDt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">拖回保管城市</div>
								<div class="field">
									<span id="provinceCity" name="provinceCity">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_33">
								<div class="label">停车场名称</div>
								<div class="field">
									<span id="parkNm" name="parkNm">&nbsp;</span>
								</div>
							</div>
				            <div class="fieldBox col_66">
								<div class="label">停车场地址</div>
								<div class="field">
									<span id="parkAddress" name="parkAddress">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">优车资产管理员</div>
								<div class="field">
									<span id="assMgs" name="assMgs">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">拖车费用(元/辆)</div>
								<div class="field">
									<span id="backPrice" name="backPrice">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">拖车数量</div>
								<div class="field">
									<span id="backQty" name="backQty" >&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">拖车费合计(元)</div>
								<div class="field">
									<span id="backAmt" name="backAmt">&nbsp;</span>
								</div>
							</div>
							<!-- 收款信息 -->
							<div class="caption">
								<span class="title">收款信息</span>
							</div>
							<div class="fieldBox col_33">
								<div class="label">收款方名称</div>
								<div class="field">
									<span id="payeeAccNm" name="payeeAccNm">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">开户银行</div>
								<div class="field">
									<span id="payeeBankNm" name="payeeBankNm">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">开户行行号</div>
								<div class="field">
									<span id="payeeBankNo" name="payeeBankNo">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">银行账号</div>
								<div class="field">
									<span id="payeeAccNo" name="payeeAccNo">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">实际拖回时间</div>
								<div class="field">
									<span id="actBackDt" name="actBackDt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label"></div>
								<div class="field"></div>
							</div>
							<!-- 付款信息 -->
							<div class="caption fkxx">
								<span class="title">付款信息</span>
							</div>
							<div class="fieldBox col_33">
								<div class="label">付款方名称</div>
								<div class="field">
									<span name="payerAccNm" id="payerAccNm">&nbsp;狮桥融资租赁（中国）有限公司</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">开户银行</div>
								<div class="field">
									<span name="payerBankNm" id="payerBankNm">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">银行账号</div>
								<div class="field">
									<span name="payerAccNo" id="payerAccNo">&nbsp;</span>
								</div>
							</div>
							<!-- 未来本金等值,实际明细 -->
							<div class="fieldBox col_33">
								<div class="label">未来本金(元)</div>
								<div class="field">
									<span name="futureAmt" id="futureAmt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">逾期租金(元)</div>
								<div class="field">
									<span name="overRentAmt" id="overRentAmt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">履约保证金(元)</div>
								<div class="field">
									<span name="performanceAmt" id="performanceAmt">&nbsp;</span>
								</div>
							</div>
							<!-- 保险保证金等值,实际明细 -->
							<div class="fieldBox col_33">
								<div class="label">保险保证金(元)</div>
								<div class="field">
									<span name="insureAmt" id="insureAmt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">其他费用(元)</div>
								<div class="field">
									<span name="otherAmt" id="otherAmt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">风险保证金(元)</div>
								<div class="field">
									<span name="riskAmt" id="riskAmt">&nbsp;</span>
								</div>
							</div>
							<!-- 实际付款时间等值,实际明细 -->
							<div class="fieldBox col_33">
								<div class="label">实际付款时间</div>
								<div class="field">
									<span id="actPayDt" name="actPayDt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">实际付款金额(元)</div>
								<div class="field">
									<span id="actPayAmt" name="actPayAmt">&nbsp;</span>
								</div>
							</div>
							<div class="fieldBox col_33">
								<div class="label">保底价款(元)</div>
								<div class="field">
									<span name="baseAmt" id="baseAmt">&nbsp;</span>
								</div>
							</div>
							<!-- 车辆交接单 -->
			                <div class="fieldBox col_33 tcjjd">
			                	<div class="label">车辆交接单</div>
			                    <div class="field">
			                        <a class="modify1" href="javascript:void(0);" onclick="entryOrder('modify1')">修改</a>
			                    </div>
			                </div>
			                <div class="fieldBox col_66 tcjjd">
			                    <div class="field">
			                         <a href="javascript:void(0);" onclick="exportAssCarHvPdf()">导出</a>
			                    </div>
			                </div>
			                <!-- 借款信息holly START-->
							<div class="caption">
								<span class="title">借款信息</span>
							</div>
							<div class="fieldBox col_100">
								<div class="sqPanel">
									<div id="detailGrid">
										<!-- 借款信息列表显示块 -->
										<div id="ligergrid_fin" class="sq-grid"></div>
									</div>
								</div>
							</div>
							<div class="fieldBox col_50">
								<div class="label  requiredSymbol"  >剩余未核销金额合计(元)</div>
								<div class="field col_50"  >
									<span id="arAmts" name="arAmts"> </span>
								</div>
							</div>
							<!-- 借款信息holly END-->
			                
			                
			                <!-- 转优车资料  -->
							<div class="caption crkzl">
								<span class="title">转优车</span>
							</div>
							<!-- 转优车说明 -->
				            <div class="fieldBox col_100">
								<div class="label">转优车说明</div>
								<div class="field">
									<textarea name="dealDesc" id="dealDesc" rows="3" class="l-textarea" style="width:98%" value="" ></textarea>
								</div>
							</div>
							<!-- 上传附件 -->
							<div class="fieldBox col_100">
								<div class="label">附件上传</div>
								<div class="field">
									<jsp:include page="../assCommFilesUpload.jsp" flush="true" >
										<jsp:param name="filePath" value="ass"/>
									</jsp:include>
									<div id="fileUpload1" class="upfileBoxs"></div>
									<span class="sq-button sq-button-hasicon" id="btnUpload1" onclick="ajaxFileUploadImg('uploads1',1)">
										<i class="sqBtnIco_9"></i>上传
									</span>
								</div>
							</div>
							<!-- 附件显示 -->
							<div class="fieldBox col_100">
								<div style="width: 98%; margin-left: 1%;">
					            	<div id="ligergrid_file1" class="sq-grid"></div>
								</div>
							</div>
							<!-- 隐藏支付表主键、支付表号 -->
			                <div class="fieldBox col_100" style="display:none;">
			                    <div class="field">
			                         <input name="tcMasterId" id="tcMasterId" type="text" class="ui-textbox" value="${tcMasterId}">
			                         <input name="tcDetailId" id="tcDetailId" type="text" class="ui-textbox" value="${tcDetailId}">
			                         <input name="tcInfoId" id="tcInfoId" type="text" class="ui-textbox" value="${tcInfoId }">
			                         <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${prjId}">
	                         		 <input name="prjPrdDtlId" id="prjPrdDtlId" type="text" class="ui-textbox" value="${prjPrdDtlId}">
			                         <input name="paySchId" id="paySchId" type="text" class="ui-textbox" value="${paySchId}">
			                         <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="${paySchNo}">
                                     <input name="contNo4Save" id="contNo4Save" type="text" class="ui-textbox" value="">
                                     <input name="enabledPaySchId" id="enabledPaySchId" type="text" class="ui-textbox" value="${enabledPaySchId}">
                                     <input name="enabledPaySchNo" id="enabledPaySchNo" type="text" class="ui-textbox" value="${enabledPaySchNo}">
			                         <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
			                         <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
			                         <input name="buOrgCd" id="buOrgCd" type="text" class="ui-textbox" value="${buOrgCd}">
			                         <input name="optimal_Id" id="optimal_Id" type="text" class="ui-textbox" value="${optimal_Id}">
			                         <!-- 以下参数为流程需要 -->
			                         <input name="businessType" id="businessType" type="text" class="ui-textbox" value="${businessType}">
			                         <input name="prjTypCd" id="prjTypCd" type="text" class="ui-textbox" value="${prjTypCd}">
			                         <input name="prjNm" id="prjNm" type="text" class="ui-textbox" value="${prjNm}">
			                         <input name="orgName" id="orgName" type="text" class="ui-textbox" value="${orgName}">
			                    </div>
			                </div>
						</div>
						<div class="btnsBox">
							<span id="saveAssOptimalBtn" class="sq-button sq-button-round" onclick="testHvData()">发起申请</span>
							<span id="closeBtn" class="sq-button sq-button-round" onclick="Remove_navTab()">关闭</span>
						</div>
					</form>
				</div>
				<!-- 页签2：借款信息 -->
				<div tabid="tabB" title="借款信息" id="tabBId" style="dis">
					<iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
				</div>
			</div>
		</div>
	</div>

    <script>
    	//加载
	    $(function() {
	    	initForm();//初始化表单
	        initData();//初始化数据
	    	loadFilesLiger("tcsq", 2, $("#tcMasterId").val());//加载拖车置申请文件列表信息
	    	loadFilesLiger("zycsq", 1, $("#optimal_Id").val());//加载转优车申请文件列表信息
	    	//加载借款信息
	    	initGrid_fin();
	    });
		
		//初始化表单
		function initForm(){
	    	$("#optimalCar").ligerForm({
				validate: true
			});
			$("#optimalCar").check_ligerFormEditor();//重新刷新页面动态字段
		};
	    
	    //初始化数据
	    function initData(){
	    	var tcMasterId = $("#tcMasterId").val();
	    	if(!tcMasterId){
	    		$.ligerDialog.SQalert({content: "拖车申请主表ID为空,无法查询相关信息！",SQ_type: "error"});
	    		return;
	    	}
	    	var wait_dialog= $.ligerDialog.SQalert({
	            content: LogUtils.LOG_CMM_LOADING,
	            SQ_type: "waitting",
	            onClose: function () {
	            }
	        });
	    	//加载设备信息
	    	initGrid_equ(tcMasterId);
	    	//加载拖车主表信息
	    	var _url = '<%=path%>/ass/assTrailCarM/getTrailCarMaster.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{tcMasterId:tcMasterId},
	    		url: _url,
	    		success:function(msg){
	    			 wait_dialog.close();
	    			 if(msg.success == 1){
	    				 setData(msg.data);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
	    }
	    /* HOLLY START*/
		//初始化借款信息
		function initGrid_fin( ){
			var paySchId = $("#paySchId").val();
			$("#ligergrid_fin").ligerGrid({
				parms:{paySchId:paySchId},
                url: '<%=path%>/finpayschfee/finance/getPaySchFeeList.do',
                method : 'get',
				columns:[
					{ display: '序号', name: 'feeRem', width: 40 , enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							return rowindex+1;
						}},
					{ display: '借款类型', name: 'feeTypCdNm', width: 150, enabledSort:true },
					{ display: '借款金额(元)', name: 'feeAmt', width: 150, enabledSort:true,render:function (rowdata, rowindex, value, column){
						return value/100;
					} },
					{ display: '实付金额(元)', name: 'feeAmt', width: 150 , enabledSort:true,render:function (rowdata, rowindex, value, column){
						return value/100;
					}},
					{ display: '已核销金额(元)', name: 'paidUpAmt', width: 150, enabledSort:true,render:function (rowdata, rowindex, value, column){
						return value/100;
					}},
					{ display: '实付时间', name: 'crtTm', width: 200, enabledSort:true,render: function (rowdata, rowindex, value, column) { 
						var dateStr = "";
						if(null != value){
							var date = new Date(value);
							dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
						}
						return dateStr;
						}},
					{ display: '付款单号', name: 'feeRem', width: 200, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h ="";
							if( rowdata.pNo != null){
				                h+='<a class="sq-button-hasicon" href="javascript:commShowFlow(';
				                h+="'"+rowdata.pinstId+"'";
				                h+=",'"+rowdata.audStsCd+"'";
				                h+=",'"+rowdata.dataId+"'";
				                h+=",'"+rowdata.formUrl+"'";
				                h+=")\"><i class='sqBtnIco_32'></i>"+rowdata.pNo+"</a>";
							}
							return h;
						}},
					{ display: '备注', name: 'feeRem', width: 200, enabledSort:true }
				],
				onAfterShowData :function (e){
					var rows=e.rows;
					var i=0;
					for ( var index in rows) {
						i+=rows[index].arAmt;
					}
					$("#arAmts").text(i/100+" 元");
				},
				usePager: false,//是否有分页便签
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				height:'100%',
				heightDiff:-2,
				isScroll: false,//是否有滚动条
				checkbox:false,//列表是否有选择框
				rownumbers:false//列表是否有行号
			});
		}
		//显示流程：流程实例ID,状态,业务主键(拖车主表ID)
	    function commShowFlow(_pInstId, _audStsCd, _businessKey,_formUrl){
	    	if(StringUtils.isEmpty(_pInstId)){
	    		UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
	    		return;
	    	}
	    	var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
	    	Add_navTab('tab_ass_trail_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
	    }
		
	    /* HOLLY END*/
	    //设置页面数据
	    function setData(data){
			//显示申请信息
			$("#applyNm").html(data.applyNm);
 	    	$("#applyDt").html(renderDate1(data.applyDt));
			$("#backReason").html(data.backReason);
			//设置用来显示的元素值
			$("#companyNm").html(data.companyNm);
			$("#backDt").html(renderDate1(data.backDt));
			$("#backPrice").html(data.backPrice / 100);
			$("#backQty").html(data.backQty);
			$("#backAmt").html(data.backAmt / 100);
			$("#payeeAccNm").html(data.payeeAccNm);
			$("#payeeBankNm").html(data.payeeBankNm);
			$("#payeeBankNo").html(data.payeeBankNo);
			$("#payeeAccNo").html(data.payeeAccNo);
			//显示拖回保管城市等信息
			$("#parkNm").html(data.parkNm);
			$("#assMgs").html(data.assManagers);
			$("#parkAddress").html(data.parkAddress);
			$("#provinceCity").html(data.provinceCity);
			//显示付款信息
			$("#payerBankNm").html(data.payerBankNm);
			$("#payerAccNo").html(data.payerAccNo);
	    }
	    
		//初始化列表
		function initGrid_equ(id){
			var flag = $("#flag").val();
			$("#ligergrid_equ").ligerGrid({
				url:'<%=path%>/ass/assTrailCarM/getTrailCarDetail.do',
				method:'get',
				parms:{tcMasterId:id},
				columns:[
					{ display: '租赁物名称', name: 'prdNm', minWidth: 160, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = rowdata.prdNm;
							initPkData(rowdata);//设置主键值及主要信息
							return h;
						}},
					{ display: '型号', name: 'prdMdl', minWidth: 150 , enabledSort:true},
					{ display: '是否新车', name: 'isNew', width: 100 , enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '否';
							if(rowdata.isNew==1){
								h = '是';
							}
							return h;
						}},
					{ display: '<font color="red">GPS是否在线</font>', name: 'isOnline', width: 120, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '';
							var online = '';
				 	    	h+='<select id="isOnline" name="isOnline">';
				 	    	h+='<option value="0" ';
				 	    	if(rowdata.isOnline==0){
				 	    		h+='selected';
				 	    		online = '否';
				 	    	}
				 	    	h+='>否</option>';
				 	    	h+='<option value="1" ';
				 	    	if(rowdata.isOnline==1){
				 	    		h+='selected';
				 	    		online = '是';
				 	    	}
				 	    	h+='>是</option></select>';
				 	    	//判断是否为显示
				 	    	if(flag!="2"){
				 	    		h = online;
				 	    	}
							return h;
						}},
					{ display: '使用期限(月)', name: 'usedPd', width: 100 , enabledSort:true},
					{ display: '单价', name: 'guidePc', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = 0;
			                h = rowdata.guidePc / 100;
							return h;
						}},
					{ display: '数量', name: 'prdQty', width: 100, enabledSort:true},
					{ display: '留购价', name: 'rsrvPc', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = 0;
			                h = rowdata.rsrvPc / 100;
							return h;
						}},
					//{ display: '买卖合同编号', name: 'salContNo', width: 100 , enabledSort:true},
					{ display: '车辆配置单', name: 'overdueAmt', width: 100, enabledSort:true,
						render: function (rowdata, rowindex, value, column) { 
							var h = '';
							h+='<a href="javascript:showOp(';
			                h+="'"+rowdata.prjId+"'";
			                h+=",'"+rowdata.prjPrdId+"'";
			                h+=")\">查看</a>";
							return h;
						}}
				],
				usePager: false,//是否有分页便签
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				isScroll: false,//是否有滚动条
				checkbox:false,//列表是否有选择框
				rownumbers:true//列表是否有行号
			});
			grid = liger.get("ligergrid_equ");
			grid.options.isSingleCheck = true;//列表是否为单选
		}
		
		//设置关键字的值-各表主键
		function initPkData(rowdata){
			//加载表单
	    	var form = liger.get("optimalCar");
			var tcDetailId = $("#tcDetailId").val();
			if(!tcDetailId){//为空执行
				form.setData({
					tcDetailId: rowdata.id,//拖车明细表ID
		    	});
			}
			form.setData({
				tcInfoId: rowdata.infoId,//拖车实际明细表ID
				paySchId: rowdata.paySchId
	    	});
			//设置支付表可查看
			var paySchNo='<a href="javascript:payDetail(';
			paySchNo+="'"+rowdata.prjPrdDtlId+"',"; //项目产品明细信息表ID
			paySchNo+="'"+rowdata.paySchId+"',"; //支付表ID
			paySchNo+="'"+rowdata.prjPrdId+"',"; //项目产品基础信息表ID
			paySchNo+="'"+rowdata.prjId+"'"; //项目基础信息表ID
			paySchNo+=')">'+rowdata.paySchNo+'</a>';
			//设置基本信息显示
 	    	$("#cstNm_1").html(rowdata.cstNm);
 	    	$("#contNo").html(rowdata.contNo);
            $("#contNo4Save").val(rowdata.contNo);
 	    	$("#paySchNo").html(paySchNo);
 	    	$("#splNm").html(rowdata.splNm);
 	    	$("#orgName_1").html(rowdata.orgName);
 	    	$("#cstMgrNm").html(rowdata.cstMgrNm);
			//设置逾期信息
			$("#lsPd").html(rowdata.lsPd);
 	    	$("#actualAmt").html(rowdata.actualAmt / 100);
 	    	$("#overdueAmt").html(rowdata.overdueAmt / 100);
 	    	$("#overdueDay").html(rowdata.overdueDay);
 	    	$("#penaltyAmt").html(rowdata.penaltyAmt / 100);
			$("#payAmt").html(rowdata.payAmt / 100);
			//初始化实际明细信息
			initDInfoData();
		}
		
	    //初始化拖车实际明细表数据
	    function initDInfoData(){
	    	var tcInfoId = $("#tcInfoId").val();
	    	if(!tcInfoId){
	    		//$.ligerDialog.SQalert({content: "拖车实际明细表ID为空,无法查询相关信息！",SQ_type: "error"});
	    		return;
	    	}else{
		    	var wait_dialog= $.ligerDialog.SQalert({
		            content: LogUtils.LOG_CMM_LOADING,
		            SQ_type: "waitting",
		            onClose: function () {
		            }
		        });
		    	//加载拖车实际明细信息
		    	var _url = '<%=path%>/ass/assTrailCarDInf/getById.do';
		    	$.ajax({
		    		type: 'get',
		    		dataType:'json',
		    		data:{tcInfoId:tcInfoId},
		    		url: _url,
		    		success:function(msg){
		    			 wait_dialog.close();
		    			 if(msg.success == 1){
		    				 setDInfData(msg.data);//设置数据
		    			 }else{
		    				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
		    			 }
		    		}
		    	});
	    	}
	    }
	    
	    //设置拖车实际明细信息
	    function setDInfData(data){
	    	$("#futureAmt").html(data.futureAmt / 100);
	    	$("#overRentAmt").html(data.overRentAmt / 100);
	    	$("#performanceAmt").html(data.performanceAmt / 100);
	    	$("#insureAmt").html(data.insureAmt / 100);
	    	$("#riskAmt").html(data.riskAmt / 100);
	    	$("#otherAmt").html(data.otherAmt / 100);
	    	$("#baseAmt").html(data.baseAmt / 100);
			$("#actPayDt").html(renderDate1(data.actPayDt));
			$("#actPayAmt").html(data.actPayAmt / 100);
			$("#actBackDt").html(renderDate1(data.actBackDt));
	    }
		
		//查看支付表详情
		function payDetail(prjPrdDtlId,id,prjPrdId,prjId){
			var editFlag = true;
			Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
		}
		
		//保存文件
		function saveFile(pkId,info){
			var docArray = JSON.stringify(getUploadResultParams(1));
	        var url = "<%=path%>/ass/assTrailCarD/uploadAttchment.do";
        	if(null == docArray){
        		//无要上传的文件-直接结束
        		top.$.ligerDialog.SQalert({content: info,SQ_type: "success"});
        		Remove_navTab();//关闭申请窗口
        	}else{
		        if(pkId){//转优车主表ID不为空执行
			        //赋值附件
			        var data = {
						"docArray":docArray,
						"pkId": pkId,
						"flag": "zycsq"
					};
					//请求
			        AjaxUtils.ajaxPost(url, data, function(msg){
			        	if(msg.success == 1){
			        		top.$.ligerDialog.SQalert({content: info,SQ_type: "success"});
							 if(msg.data){
								 //清空上传文件缓存
								 clearUploadResultParams(1);
							 }
							 Remove_navTab();//关闭申请窗口
						 }else{
							 UIUtils.alertError(msg.info);
						 }
			        }, true);
		        }else{
		        	$.ligerDialog.SQalert({content: "业务主键为空-不能保存文件！",SQ_type: "error"});
		        }
        	}
		}
		
		//显示已上传但是未保存的文件列表
		function showFiles(data, index){
			var applyNm = $("#applyNm").html();
			var applyDt = $("#applyDt").html();
			var f_Grid = liger.get("ligergrid_file"+index);
			var uploadJOSN = data;
    		for (var i=0; i< uploadJOSN.length; i++){ 
        		//添加行-追加行
        		f_Grid.addRow({fileNm: uploadJOSN[i].fileNm, crtUsrRlNm: applyNm, crtTm: applyDt, doSthFlag: "1", ligerIndex: index});
    		}
		}

		var isNew = '${isNew}';
		//验证交接单信息是否已维护
	    function testHvData(){
	    	$.ligerDialog.confirm('确定发起流程吗?', function (flag) {
				if(flag == false)return;
				var ligerForm = liger.get("optimalCar");
				if (!ligerForm.valid()) {
					$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
					return false; //验证不通过，不执行以下代码
				}
				//获取拖车信息明细表ID-为空提示
				var tcDetailId = $("#tcDetailId").val();
				if(!tcDetailId){
					$.ligerDialog.SQalert({content: "拖车明细信息不存在,不能发起转优车流程！",SQ_type: "warning"});
					return false;
				}else{
					//验证交接单信息是否已维护
			    	var _url = '<%=path%>/ass/assTrailCarM/getHvInfoByDetailId.do';
			    	$.ajax({
			    		type: 'get',
			    		dataType:'json',
			    		data:{tcDetailId:tcDetailId},
			    		url: _url,
			    		success:function(msg){
							if(msg.success == 1 && null != msg.data){
								var hv = msg.data;
								if (isNew == '1') {
                                    saveAssOptimal();//保存转优车申请信息（转优车信息主表）
                                } else {
                                    //判断违章信息是否已填
                                    if (hv.illegalThree == null || hv.illegalSix == null || hv.illegalTwelve == null) {
                                        $.ligerDialog.SQalert({
                                            content: "请维护交接单中的必填信息,否则不能发起转优车流程！",
                                            SQ_type: "warning"
                                        });
                                        return false;
                                    } else if (hv.isTransfer == null || hv.isAccident == null) {//检查过户和事故情况
                                        $.ligerDialog.SQalert({
                                            content: "请维护交接单中的必填信息,否则不能发起转优车流程！",
                                            SQ_type: "warning"
                                        });
                                        return false;
                                    } else {
                                        saveAssOptimal();//保存转优车申请信息（转优车信息主表）
                                    }
                                }
			    			}else{
			    				$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			    			}
			    		}
			    	});
				}
	    	});
		
	    }
		
		//保存转优车申请信息（转优车信息主表）
		function saveAssOptimal(){
			var ligerForm = liger.get("optimalCar");
			var data = ligerForm.getData();//获取表单数据
			console.log(data);
			//新增赎回信息主表数据
			var wait_dialog = null;
			var url = '<%=path%>/ass/assTrailCarD/addOptimalInfo.do';
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: url,
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
				},
				success:function(msg){
					wait_dialog.close();
					//返回的赎回信息主表ID不为空执行一下操作
					if(msg.success == 1 && null != msg.data){
						saveFile(msg.data,msg.info);//保存文件
					}else{
						top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				}
			});
		}
		
		//入库交接单
		function entryOrder(crflag){
			var tcMasterId = $("#tcMasterId").val();//拖车主表ID
			var tcDetailId = $("#tcDetailId").val();//拖车明细ID
			var paySchId = $("#paySchId").val();//支付表ID
			var paySchNo = $("#paySchNo").val();//支付表号
			var prjId = $("#prjId").val();//项目ID
			var param = '&&tcMasterId='+tcMasterId+'&&tcDetailId='+tcDetailId+'&&crflag='+crflag;
			param += '&&paySchId='+paySchId+'&&paySchNo='+paySchNo+'&&prjId='+prjId;
			Add_navTab('entryOrder'+tcDetailId,'车辆交接单','<%=path%>/ass/assTrailCarM/toWarehousePage.do?' + param);
		}
		
		//导出车辆交接单PDF
	    function exportAssCarHvPdf(){
	    	var tcDetailId = $("#tcDetailId").val();//拖车明细ID
	        window.location.href='<%=path%>/ass/assTrailCarD/exportAssCarHvPdf.do?tcDetailId='+tcDetailId;
	    }
		
		//车辆配置单
		function showOp(_prjId,_prjPrdId){
		    Add_navTab("corePrcBook"+_prjPrdId, "车辆配置单", '<%=path%>/audit/audStandingBook/toCorePrcBookAddPage.do?prjPrdId='+_prjPrdId+'&proIntId='+$("#proIntId").val()+'&projectId='+_prjId+'&isDetail='+1);
		}
    </script>
</body>
</html>